﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using BO.Infrastructure.Utils;
using BO.Infrastructure.StaticData;

namespace GUI.Controls.Photo
{
    public partial class HighlightPhoto : System.Web.UI.UserControl
    {
        //private const string Format = "<li class="slide">{0}
        //        <img class="thumbnail" src="http://sliderpro.net/wp-content/plugins/slider-pro/includes/timthumb/timthumb.php?q=95&amp;w=140&amp;h=80&amp;a=c&amp;zc=1&amp;src=http://sliderpro.net/wp-content/uploads/2012/11/image1.jpg" alt="" />
        //    </li>"

        private const int ImageWidth = 634;
        private const int ImageHeight = 350;
        private const int ThumbWidth = 84;
        private const int ThumbHeight = 54;

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        internal bool DataBind(System.Data.DataTable dt)
        {
            if (dt != null && dt.Rows.Count > 0)
            {
                ltrTitle.Text = dt.Rows[0][SqlConstants.NewsPublish.Title].ToString();
                ltrTitle.Text = dt.Rows[0][SqlConstants.NewsPublish.Sapo].ToString();
                var sb = new StringBuilder();
                foreach (DataRow r in dt.Rows)
                {
                    var image = PresentationUtils.Photo.BuildPhoto(r[SqlConstants.PhotoPublished.ImageUrl].ToString(), r[SqlConstants.NewsPublish.Title].ToString(), ImageWidth,
                                                                    ImageHeight);
                    var thumb = PresentationUtils.Photo.BuildPhoto(r[SqlConstants.PhotoPublished.ImageUrl].ToString(), r[SqlConstants.NewsPublish.Title].ToString(), ThumbWidth,
                                                                   ThumbHeight);
                    sb.AppendFormat("<li class=\"slide\">{0}{1}</li>",
                        image, thumb);
                }
                ltrData.Text = sb.ToString();
                return true;
            }
            return false;
        }
    }
}